define(async () => {

    async function loadImage(url) {
        const image = new Image();
        image.src = url;
        return new Promise((resolve, reject) => {
            image.onload = () => resolve(image);
            image.onerror = err => reject(err);
            image.onabort = () => reject(new Error("image resource load aborted"));
        });
    }

    async function loadVideo(url) {
        const videoDom = document.createElement("video");
        videoDom.src = url;
        document.body.appendChild(videoDom);
        return new Promise((resolve, reject) => {
            videoDom.onload = () => resolve(videoDom);
            videoDom.onerror = err => reject(err);
            videoDom.onabort = () => reject(new Error("video resource load aborted"));
        });
    }

    async function loadAudio(url) {
        const videoDom = document.createElement("audio");
        videoDom.src = url;
        document.body.appendChild(videoDom);
        return new Promise((resolve, reject) => {
            videoDom.onload = () => resolve(videoDom);
            videoDom.onerror = err => reject(err);
            videoDom.onabort = () => reject(new Error("audio resource load aborted"));
        });
    }

    return {
        loadImage,
        loadVideo,
        loadAudio
    };
});